﻿using System.Linq;
using WalkingTec.Mvvm.Core;
using SelfService.Model.Models;


namespace SelfService.ViewModel.SysConfigGroupVMs
{
    public partial class SysConfigGroupVm : BaseCRUDVM<SysConfigGroup>
    {

        public SysConfigGroupVm()
        {
        }

        protected override void InitVM()
        {
        }

        public override void Validate()
        {
            if (DC.Set<SysConfigGroup>().Any(e => e.Key == Entity.Key && e.ID != Entity.ID))
            {
                this.MSD.AddModelError("Entity.Key", "Key不能重复");
            }
            if (DC.Set<SysConfigGroup>().Any(e => e.Name == Entity.Name && e.ID != Entity.ID))
            {
                this.MSD.AddModelError("Entity.Key", "名称不能重复");
            }
        }

        public override void DoAdd()
        {           
            base.DoAdd();
        }

        public override void DoEdit(bool updateAllFields = false)
        {
            base.DoEdit(updateAllFields);
        }

        public override void DoDelete()
        {
            base.DoDelete();
        }
    }
}
